package com.xyz.study.redis;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * RedisMain
 *
 * @author XYZ
 * @version 1.0.0
 * @since  2020/7/6
 */
//@Component
public class RedisTest {

    private RedisTemplate redisTemplate;

    private RedisTemplate manualRedisTemplate;

    @Autowired
    public void setRedisTemplate(RedisTemplate redisTemplate, @Qualifier("manualRedisTemplate")RedisTemplate manualRedisTemplate) {
        this.redisTemplate = redisTemplate;
        this.manualRedisTemplate = manualRedisTemplate;
    }

    @PostConstruct
    public void redisTest(){
        redisTemplate.opsForValue().set("k1", "v1");
        System.out.println(redisTemplate.opsForValue().get("k1"));
        manualRedisTemplate.opsForValue().set("k2", "v2");
        System.out.println(manualRedisTemplate.opsForValue().get("k2"));
    }
}
